package com.huawei.appmarket.service.store.awk.card;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.Color;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;
import com.huawei.appgallery.foundation.card.base.bean.BaseDistCardBean;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.appgallery.foundation.ui.framework.widget.button.DownloadButton;
import com.huawei.appmarket.service.store.awk.bean.SubstanceListCardBean;
import com.huawei.appmarket.support.video.VideoPlayer;
import o.azb;
import o.cgz;
import o.dke;
import o.Logger;
import o.dof;
import o.ContentManager;
import o.eho;
import o.eqx;
import o.erq;
import o.evf;
import o.evo;
import o.evo.e;
import o.evp.b;
import o.evq;
import o.evt;
import o.ewm;
import o.ewm.c;
import o.ewm.d;
import o.ewm.h;
import o.ewm.j;

public class SubstanceListCardVideoItem extends AbstractSubstanceListItemCard implements e {
    private TextView ʻ;
    private View ʼ;
    private TextView ʽ;
    private boolean ˊॱ;
    private VideoPlayer ˋ;
    private int ˋॱ = 0;
    private TextView ॱॱ;
    private TextView ᐝ;

    public SubstanceListCardVideoItem(Context context) {
        super(context);
    }

    public cgz ˏ(View view) {
        ˋ((DownloadButton) view.findViewById(j.ᐨᐝ));
        this.ˋ = (VideoPlayer) view.findViewById(j.ˊʴ);
        this.ʽ = (TextView) view.findViewById(j.ˉᶥ);
        evq o_evo = new evo(this.ˋ.getContext(), h.ˉᐝ);
        this.ˋ.setController(o_evo);
        o_evo.setPosterVisibleListener(this);
        this.ʻ = (TextView) view.findViewById(j.ˊˇ);
        this.ᐝ = (TextView) view.findViewById(j.ˉᐧ);
        this.ʼ = view.findViewById(j.ˉꜞ);
        this.ॱॱ = (TextView) view.findViewById(j.ㆍʼ);
        return this;
    }

    public void ˏ(CardBean cardBean) {
        super.ˏ(cardBean);
        SubstanceListCardBean substanceListCardBean = (SubstanceListCardBean) cardBean;
        String str = (String) this.ᐝ.getTag();
        if (dof.ˋ(str) || !str.equals(substanceListCardBean.ʻᐝ())) {
            if (TextUtils.isEmpty(substanceListCardBean.ʽˋ())) {
                this.ʽ.setVisibility(8);
            } else {
                this.ʽ.setVisibility(0);
                this.ʽ.setText(substanceListCardBean.ʽˋ());
            }
            if (substanceListCardBean.ٴ() != 0) {
                this.ᐝ.setText(substanceListCardBean.ߴ());
            } else {
                this.ᐝ.setText(substanceListCardBean.ʽˊ());
            }
            this.ᐝ.setTag(substanceListCardBean.ʻᐝ());
            this.ʻ.setText(substanceListCardBean.ʾॱ());
            Context ˋ = ContentManager.getInstant().getContext();
            eqx.ˋ(ˋ.getResources().getDimensionPixelSize(d.ᐝᐝ), ˋ.getResources().getDimensionPixelSize(d.ॱʻ), this.ˋ.ॱॱ(), substanceListCardBean.ʻᐝ());
            this.ˋ.setVideoBaseInfo(new b().ˎ(substanceListCardBean.ʽᐝ()).ˊ(substanceListCardBean.ʻᐝ()).ˋ(substanceListCardBean.ʻˋ()).ˏ(substanceListCardBean.ͺˏ()).ॱ(substanceListCardBean.u_()).ʼ(substanceListCardBean.ᐝʻ()).ᐝ(substanceListCardBean.ॱﾟ()).ʻ(evt.ˏ(substanceListCardBean.sp_)).ॱॱ(substanceListCardBean.ॱـ()).ॱ());
            ˋ(this.ॱॱ, substanceListCardBean.ˋʻ());
            ᐝ(this.ᐝ);
            boolean z = 1 == substanceListCardBean.ॱꜟ() && !dof.ˋ(substanceListCardBean.ʾ());
            this.ˊॱ = z;
            if (this.ˊॱ && !TextUtils.isEmpty(substanceListCardBean.ॱˌ())) {
                eqx.ॱ(ˋ, substanceListCardBean.ॱˌ(), null);
            }
            if (this.ˋॱ == substanceListCardBean.ॱﾞ() || TextUtils.isEmpty(substanceListCardBean.ॱꞌ())) {
                ˊ(true);
                return;
            }
            try {
                int parseColor = Color.parseColor(substanceListCardBean.ॱꞌ());
                this.ʼ.setBackgroundColor(parseColor);
                boolean ˏ = erq.ˏ(parseColor);
                parseColor = -16777216;
                this.ᐝ.setAlpha(azb.ˋ(this.ʼॱ, d.ߺ));
                if (ˏ) {
                    parseColor = -1;
                    this.ᐝ.setAlpha(azb.ˋ(this.ʼॱ, d.ॱʿ));
                }
                parseColor = this.ʼॱ.getResources().getColor(parseColor);
                this.ʻ.setTextColor(parseColor);
                this.ᐝ.setTextColor(parseColor);
                ˊ(false);
            } catch (Exception e) {
                Logger.e("SubstanceListCardVideoItem", e.toString());
                ˊ(true);
            }
        } else if (Logger.ˎ()) {
            Logger.ˏ("SubstanceListCardVideoItem", "cardInfoBean.getBannerUrl_() = " + substanceListCardBean.ʻᐝ());
        }
    }

    public void ˋ(int i) {
        if (this.ʽ == null) {
            return;
        }
        if (TextUtils.isEmpty(this.ʽ.getText())) {
            this.ʽ.setVisibility(8);
        } else {
            this.ʽ.setVisibility(i);
        }
    }

    public void ॱ(BaseDistCardBean baseDistCardBean) {
        super.ॱ(baseDistCardBean);
        if (ʽ() == null) {
            return;
        }
        if (this.ˊॱ) {
            ʽ().setVisibility(0);
        } else {
            ʽ().setVisibility(8);
        }
    }

    private void ˊ(boolean z) {
        if (ʽ() != null) {
            if (this.ˊॱ) {
                ʽ().setVisibility(0);
                int i = ewm.e.ﾞ;
                int i2 = c.ˊˊ;
                if (evf.ˊ(ʽ())) {
                    new eho(i2, i, c.ᐝॱ).ॱ(ʽ());
                } else {
                    ʽ().setButtonStyle(new dke(this.ᐝ.getContext(), this.ʼॱ.getResources().getColor(i2), -16777216, i, false, erq.ˊ(-1, 0.6f)));
                    ʽ().setIsImmersion(true);
                    ʽ().ॱ();
                }
            } else {
                ʽ().setVisibility(8);
            }
        }
        if (z) {
            Resources resources = this.ʼॱ.getResources();
            this.ʼ.setBackgroundColor(resources.getColor(c.ˋॱ));
            this.ʻ.setTextColor(resources.getColor(c.ˏॱ));
            this.ᐝ.setTextColor(resources.getColor(c.ॱˊ));
        }
    }
}
